<?php

// Library File
include '../lib/library.php';


$message_id = $_GET['message_id'];
$mode = $_GET['mode'];

if($mode == 'update'){
	
	$query = mysql_query("SELECT * FROM messages WHERE message_id='$message_id'");
	$message_array = mysql_fetch_assoc($query);
	
	// If message is read
	if($message_array['readbool']){
		$query = mysql_query("UPDATE messages SET readbool='0' WHERE message_id='$message_id' LIMIT 1");
	// Else if message is unread
	}else{
		$query = mysql_query("UPDATE messages SET readbool='1' WHERE message_id='$message_id' LIMIT 1");
	}
}else if($mode == 'delete'){
	
	mysql_query("DELETE FROM messages WHERE message_id='$message_id' LIMIT 1");
}

?>